/*
 *  Copyright 2022 Collate.
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *  http://www.apache.org/licenses/LICENSE-2.0
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

@import (reference) '../../../styles/variables.less';

@lineage-breadcrumb-panel: 50px;
@lineage-toolbar-height: 12px;
@lineage-card-header-height: 74px; // Card header in Flow Chart

.custom-react-flow {
  .react-flow__node-input.selectable.selected {
    box-shadow: none;
  }
}

.custom-node-header {
  margin: -2px -8px;
  padding-left: 8px;
  padding-right: 8px;
  border-radius: 4px;
  position: relative;
  font-size: 14px;
  font-weight: 600;
}

.custom-node-header-tracing {
  border: 1px solid @primary-color;

  .react-flow__handle {
    border-color: @primary-color;
  }

  .lineage-node-handle {
    border: 1px solid @primary-color;

    svg {
      color: @primary-color;
    }
  }
}

.data-quality-failed-custom-node-header {
  .custom-node-header-column-tracing {
    border-color: @red-14;
    color: @red-20;
    .custom-node-column-label {
      color: inherit;
    }
    .profiler-item {
      color: black;
    }
  }
}

.data-quality-failed-custom-node-header {
  &.custom-node-header-normal {
    border: 1px solid @red-3;
    .lineage-node-badge-container {
      border-color: @red-3;
    }
  }

  .react-flow__handle {
    border-color: @red-3;
  }

  .lineage-node-handle {
    border: 1px solid @red-3;

    svg {
      color: @red-3;
    }
  }

  &.custom-node-header-active {
    border-color: @red-3;
  }
}

.custom-node-header-active {
  border-color: @primary-color;
}

.custom-node-column-lineage {
  background: @background-primary;
  border: 10px solid;
  border-radius: 4px;

  .custom-node-column-lineage-body {
    display: flex;
    flex-direction: column;
    row-gap: 10px;
    position: relative;

    .custom-node-column-container {
      padding: 4px;
      position: relative;
    }
  }
}

.custom-node {
  .custom-node-header-active {
    .react-flow__handle {
      opacity: 0;
    }

    .custom-lineage-heading {
      color: @white;
    }
  }
}

.lineage-card {
  .ant-select.custom-control-search-box {
    width: 320px;
    height: 40px;

    .ant-select-selector {
      border-radius: 10px;
      border: 1px solid @border-color-6;
      background: @grey-50;
      height: 40px;

      .ant-select-selection-search-input {
        height: 40px;
        &::placeholder {
          color: @grey-21;
          font-weight: 300;
        }
      }

      .ant-select-selection-placeholder,
      .ant-select-selection-item {
        padding: 4px 12px 4px 0;
      }
    }

    .ant-input-affix-wrapper:focus,
    .ant-input-affix-wrapper-focused {
      box-shadow: none;
    }
  }
}

.lineage-header-edit-mode {
  margin-left: @lineage-sidebar-width;
}

.custom-control-zoom-slide {
  display: flex;
  column-gap: 8px;
  height: 32px;
  width: 150px;
}

.custom-node-expand-button {
  top: -14px;
  left: -12px;
  cursor: pointer;
  z-index: 1;
}

.load-more-node {
  border: 3.5px dashed @primary-color;
  border-radius: 18px;
  text-align: center;
  color: @primary-color;
  font-weight: 600;
  padding: 0.5rem;

  .load-more-node-sizes {
    color: @text-color;
  }
}

.control-button {
  display: flex;
  align-items: center;
  justify-content: center;
}

.custom-control-edit-button {
  display: block !important;
  border: 1px solid @border-color;
  background-color: @background-primary;

  &.active {
    background-color: @primary-color;
  }

  &.active:hover {
    background-color: @primary-color;
  }

  &.active:focus {
    background-color: @primary-color;
  }
}

.custom-lineage-heading {
  color: @text-grey-muted;
}

.suggestion-node-item {
  position: absolute;
  left: -10px;
  min-width: 230px;
  width: max-content;
  z-index: 20;
  background-color: @white;
  color: @text-color;
}

.lineage-card .react-flow__edge.animated path {
  animation: none;
}

.entity-lineage.sidebar {
  height: 100%;
  background: @white;
  position: absolute;
  top: 0;
  left: 0;
  width: @lineage-sidebar-width;
  z-index: 200;
  overflow-y: auto;
  padding: 8px;
  transform: translateX(100%);
  display: none;
  border-right: 1px solid @border-color;
  transition: transform 0.3s ease-out;
}

.entity-lineage.sidebar.open {
  transform: translateX(0);
  display: block;
  padding-top: 20px;
}

.loading-card {
  position: relative;
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
}

.lineage-root {
  position: relative;
  height: 100%;

  .entity-panel-container {
    right: 16px;
    margin-top: 12px;

    .ant-drawer-content-wrapper {
      border-radius: 10px;
      overflow: hidden;
    }
  }
}

// lineage
.lineage-card {
  .ant-card-body {
    height: calc(
      100vh - @om-navbar-height - @lineage-card-header-height - 280px
    ); // 280 for  DataAsset header
  }

  // lineage and it's children's always should be ltr
  direction: ltr;

  * {
    direction: ltr;
  }
}

.full-screen-lineage {
  position: fixed;
  top: @om-navbar-height;
  left: @sidebar-width;
  width: calc(100% - @sidebar-width);

  &.sidebar-collapsed {
    left: calc(72px + @padding-mlg);
    width: calc(100% - 72px - @size-xl);
  }

  &.sidebar-expanded {
    left: calc(228px + @padding-mlg);
    width: calc(100% - 228px - @size-xl);
  }

  .lineage-card {
    .ant-card-body {
      // Navbar - breadcrumb
      height: calc(100vh - @om-navbar-height - 140px);
      // 120px for card header and breadcrumb + bottom padding 20px
      overflow-y: auto;
    }
  }

  .entity-panel-container {
    top: calc(@lineage-breadcrumb-panel + @lineage-toolbar-height);
    margin-top: 0;
  }

  .lineage-container {
    height: 100%;
  }
}

.lineage-node-remove-btn {
  position: absolute !important;
  top: -20px;
  right: -20px;
  cursor: pointer;
}

.react-flow__attribution {
  display: none;
}

.react-flow__controls-button {
  width: 20px;
  height: 20px;
}

.custom-edge-pipeline-button {
  background-color: @background-primary;
  color: @primary-color;

  &.green {
    background: @green-6;
    border: 1px solid @green-7;
    color: @green-7;
  }

  &.amber {
    background: @yellow-5;
    border: 1px solid @yellow-6;
    color: @yellow-6;
  }

  &.red {
    background: @red-6;
    border: 1px solid @red-7;
    color: @red-7;
  }

  svg {
    color: inherit;
  }
}

.ant-tag.amber {
  background: @yellow-5;
  color: @yellow-6;
  border: 1px solid @yellow-6;
  margin: 0;
}

.ant-tag.red {
  background: @red-6;
  border: 1px solid @red-7;
  color: @red-7;
  margin: 0;
}

.ant-tag.green {
  background: @green-6;
  border: 1px solid @green-7;
  color: @green-7;
  margin: 0;
}

@keyframes blink {
  0% {
    border: 1px solid @primary-color;
  }

  50% {
    border: 3px solid @primary-color;
  }

  100% {
    border: 1px solid @primary-color;
  }
}

@keyframes blink-success {
  0% {
    border: 1px solid @green-7;
  }

  50% {
    border: 3px solid @green-7;
  }

  100% {
    border: 1px solid @green-7;
  }
}

@keyframes blink-amber {
  0% {
    border: 1px solid @yellow-6;
  }

  50% {
    border: 3px solid @yellow-6;
  }

  100% {
    border: 1px solid @yellow-6;
  }
}

@keyframes blink-red {
  0% {
    border: 1px solid @red-7;
  }

  50% {
    border: 3px solid @red-7;
  }

  100% {
    border: 1px solid @red-7;
  }
}

.blinking-border {
  animation: blink 1s infinite;
}

.blinking-green-border {
  animation: blink-success 1s infinite;
}

.blinking-amber-border {
  animation: blink-amber 1s infinite;
}

.blinking-red-border {
  animation: blink-red 1s infinite;
}

.react-flow__panel.left {
  &.edit-mode {
    left: @lineage-sidebar-width;
  }
}
.react-flow__panel.right {
  right: 24px;
}

.react-flow__panel {
  margin: 16px !important;
}

.react-flow__minimap {
  &.bottom.right {
    bottom: 60px;
  }
  height: 150px;
  border: 1px solid @border-color;
  border-radius: 10px;
  overflow: hidden;
}
